﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MakeIT.Deo.Negocios;
using System.IO;

namespace MakeIT.Deo.Apresentacao
{
    public partial class DownNoticia : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            //Recupera dados
            NoticiaBO noticiaBO = new NoticiaBO();
            noticia noticiaVO = noticiaBO.RecuperaNoticia(int.Parse(Request["idNoticia"]));

            if (noticiaVO != null && !(noticiaVO.Foto == null))
            {
               Response.ContentType = noticiaVO.Mime;
               Response.BinaryWrite(noticiaVO.Foto);
            }
            else
            {
                Response.ContentType = "image/png";
                string filePath = HttpContext.Current.Server.MapPath("~/App_Themes/Padrao/imagens/masterPage/SemFoto.png");
                Response.BinaryWrite(File.ReadAllBytes(filePath));
            }
        }
    }
}
